home *** CD-ROM | disk | FTP | other *** search
- /* Wizout.cc Output classes for Borland's Visual dBASE 7 Web Wizard
- (c) 1997 Borland International, all rights reserved
-
- Purpose These classes perform three functions for the three
- application types supported by the Web Wizard
-
- Data-Entry Application
- Streams starting HTML page with form and fields
- Streams .prg for CGI back-end processing (updating rowset)
- Compiles .prg and Builds executable to run server-side
-
- Query and Response Application
- Streams starting HTML page with initial search criteria control
- Modifies .REP file specified by user
- Generates .prg for CGI back-end processing (run report)
- Modifies second .REP file to respond to Href from first report
-
- Publish Application
- Modifies report properties to generate HTML Output to
- specified web site folder
- Runs report Output to web site folder
-
- Author A.A.Katz, KSoft, Inc. under contract to Borland
-
- Versions: Version 1.0 10-14-1997
-
- */
-
-
-
- //////////Class Wizout///////////////////////////////////////////////////
- //////////Purpose: Instantiates object, received parent form param//////////
-
- class WizOut(oForm)
- this.cCurrPath = Set('Directory') // store path
- this.oForm = oForm
- this.home = substr(program(1),1,rat('\',program(1)))
- this.bCopyAll = false
- this.cReportPath = ''
- this.cReportName = ''
- this.cCgiPath = ''
- this.cCgiFolder = ''
- this.cHTMLPath = ''
- this.cClass = ''
- // ////////////////////Method: StreamHTML//////////////////////////
- ///////////////////////Purpose: Generates starting HTML page ///////////////
- ///////////////////////Returns: True, if successful/////////////////////////
-
- /* Note: StreamHTML has four sections in the following order:
- Live Publish Reports
- Static Publish Reports // do nothing
- Data-Entry
- Query
- */
-
- function StreamHTML()
-
-
- ////// no HTML is streamed for live Publish Reports, only CGI
- ////// streaming is done at runtim
-
- ////// Static Publish Reports
- If this.oForm.cWizardType = 'Publish'
- this.oForm.Progress1.value = 10
- ////// extract names from full path to .REP file
- this.cReportPath = trim(this.oForm.PublishReportField.value)
-
- ////// report name
- if at('\',this.cReportPath) > 0
- this.cReportName = substr(this.cReportPath,;
- rat('\',this.cReportPath)+1)
- else
- this.cReportName = this.cReportPath
- endif
-
- ////// remove extensions
- if at('.',this.cReportName) > 0
- this.cReportName = substr(this.cReportName,1,;
- at('.',this.cReportName)-1)
- endif
-
- this.oForm.Progress1.value = 20
-
- ////// Set up target paths for both publish reports
- if this.oForm.LiveReportRadio.value
- this.oForm.Progress1.value = 90
-
- this.cCGIFolder = trim(this.oForm.PublishCGIField.value)
- if right(this.cCGIFolder,1) # '\'
- this.cCGIFolder += '\'
- endif
- this.oForm.Progress1.value = 0
- return true /////// all done for Live Publish Reports
-
- else
-
- ////// clean up HTML path
- this.cHTMLPath = trim(this.oForm.PublishCGIField.value)
- if right(this.cHTMLPath,1) # '/'
- this.cHTMLPath += '/'
- endif
-
- endif
-
- ////// Paste together HTMLPath for this report
- this.cOutPutPath = this.cHTMLPath+this.cReportName+'.htm'
-
- // Open report file and get classname
-
- this.oForm.Progress1.value = 40
- fRep = new File()
-
- try
-
-
- fRep.Open(this.cReportPath,"R")
-
- catch(Exception e)
-
- msgbox(e.Message,'Fail Open',16)
- return false
-
- endtry
-
- this.cClass = ''
-
-
- ////// Extract classname
- do
- ////// Get next line in .rep file
-
- cStr = Upper(fRep.Gets())
-
- ////// if it's the class definition line
-
- if at('CLASS',cStr) > 0 and at('OF',cStr) > 0 and;
- at('REPORT',cStr) > 0
-
- ////// parse out the class name
- this.cClass = trim( ltrim( substr(cStr,at('CLASS',cStr)+5) ) )
- this.cClass = trim( ltrim( substr(this.cClass,1, at(' OF ',this.cClass)-1) ) )
-
- exit
-
- endif
-
- until fRep.eof()
-
- fRep.Close()
- fRep = ''
-
- this.oForm.Progress1.value = 70
-
- ////// No class declaration found
- if len(trim(this.cClass)) = 0
-
- msgbox('Unable to find Report Class in '+this.cReportName,;
- 'Cannot find class',16)
- return false
- endif
-
- ////// try to instantiate the report class
- try
-
- cClass = this.cClass
- set proc to (this.cReportPath) addi
- this.oRep = new &cClass.()
-
- catch (Exception e)
-
- ////// if fail, go back
- msgbox(e.Message,'Fail Instantiation',16)
- return false
-
- EndTry
-
- this.oForm.Progress1.value = 80
-
- this.oRep.Output = 4 // HTML
- this.oRep.OutputFileName = this.cOutPutPath
-
- try
- this.oRep.Render()
-
- catch (Exception e)
-
- msgbox('Error rendering report'+chr(13)+;
- e.message,'Report Error',16)
- return false
- endtry
-
- this.oForm.Progress1.value = 100
- ////// Clean up
- Close Proc (this.cReportPath)
- this.oRep = ''
-
- this.oForm.Progress1.value = 0
- return true
-
- endif
-
-
-
- //////////// Wizards that require HTML pages (Query and Data-Entry)
-
- this.bCopyAll = false // reset "yes to all"
- local n // init as counter for various loops
- this.BackGroundImage = ''
- this.LogoImage = ''
- this.MailImage = ''
- this.HomeImage = ''
-
- /////////////Make sure output filename is clean
- this.cOutputFile = ltrim(trim(this.oForm.FileNameField.value))
-
- if at('.',this.cOutputFile) > 0
- this.cOutputfile = substr(this.cOutputFile,1,at('.',this.cOutputFile)-1)
- endif
-
- if at('/',this.cOutputFile) > 0
- this.cOutputFile = substr(this.cOutputfile,;
- rat('\',this.cOutputFile)+1)
- endif
-
-
- //////////Clean up URL and set CGI EXE Name with full web path
- this.cCGIUrl = ltrim(trim(this.oForm.UrlField.value))
- if substr(this.cCgiUrl,len(this.cCgiUrl),1) # '/'
- this.cCgiUrl += '/'
- endif
- if substr(upper(this.cCgiUrl),1,7) # 'HTTP://'
- this.cCgiUrl = 'http://'+this.cCgiUrl
- endif
- this.cCgiUrlBat = this.cCgiUrl+this.cOutputFile+'.Bat'
-
-
- //////////////// Initialize and test CGI folder
- this.cCgiPath = this.oForm.CGIPathField.value
- if empty(this.cCGIPath)
- return false
- endif
- this.cCgiPath = Class::CleanUpFolder(this.cCGIPath)
-
- this.cCgiFileName = this.cCgiPath+this.cOutputFile+'.exe'
- //CGI path is formatted properly and tested
-
-
- this.cCGIFolder = this.cCgiPath
-
-
- /////////////// Initialize and test HTML folder
- this.cHTMLPath = this.oForm.HTMLPathField.value
- if empty(this.cHTMLPath)
- msgbox('Web Site HTML path required to finish application.')
- return false
- endif
- this.cHtmlPath = Class::CleanUpFolder(this.cHTMLPath)
-
- //HTML path is formatted properly and tested
-
-
-
- //Add HTML Path to HTML File name
- this.cHtmlFileName = this.cHtmlPath+this.cOutputFile+'.htm'
-
- // test for duplicates
- if file(this.cHTMLFileName)
- if msgbox('Filename: '+this.cHTMLFileName+' already exists! '+;
- 'Overwrite?','Duplicate Filename',36) # 6
- return false
- endif
- dele file (this.cHTMLFileName)
- endif
-
- // get reportpath and reportname
- this.cReportPath = trim(this.oForm.FirstReportField.value)
- ////// report name
- if at('\',this.cReportPath) > 0
- this.cReportName = substr(this.cReportPath,;
- rat('\',this.cReportPath)+1)
- else
- this.cReportName = this.cReportPath
- endif
- ////// remove extensions
- if at('.',this.cReportName) > 0
- this.cReportName = substr(this.cReportName,1,;
- at('.',this.cReportName)-1)
- endif
-
- //////////// Copy in graphic images for background, home and mail
- //////////// Note: bad files or paths are not treated as critical
- //////////// errors since the Browser just puts a "broken image"
- //////////// logo on the HTML page. Warnings, however, are given
-
- //////////// each image is removed from datasources so that it can
- //////////// be copied, and then restored when done.
- this.oform.progress1.value = 10
- cd (this.home) // go back to home directory
-
- cBkg = this.oForm.Background
- cDsc = this.oForm.BackgroundDisplay.DataSource
- this.oForm.Background = 'FILENAME Blank.gif'
- this.oForm.BackgroundDisplay.DataSource = 'FILENAME Blank.gif'
-
- this.BackgroundImage = class::CopyGraphicFile(this.oForm.BackgroundImageField.value)
- this.oForm.Background = cBkg
- this.oForm.BackgroundDisplay.DataSource = cDsc
-
-
- cDsc = this.oForm.HomeImage.DataSource
- this.oForm.HomeImage.DataSource = 'FILENAME Blank.gif'
-
- this.HomeImage = class::CopyGraphicFile(this.oForm.HomeImageField.value)
- this.oForm.HomeImage.DataSource = cDsc
-
-
- cDsc = this.oForm.MailImage.DataSource
- this.oForm.MailImage.DataSource = 'FILENAME Blank.gif'
-
- this.MailImage = class::CopyGraphicFile(this.oForm.MailImageField.value)
- this.oForm.MailImage.DataSource = cDsc
-
-
- cDsc = this.oForm.LogoImage.DataSource
- this.oForm.LogoImage.DataSource = 'FILENAME Blank.gif'
-
- this.LogoImage = class::CopyGraphicFile(this.oForm.LogoImageField.value)
- this.oForm.LogoImage.DataSource = cDsc
-
-
- this.oform.progress1.value = 40
-
- // Create HTML file with low-level IO
-
- if file(this.cHtmlFileName)
- dele file (this.cHtmlFileName)
- endif
- this.nHnd = fCreate(this.cHtmlFileName)
-
- if this.nHnd < 0
- msgbox('Cannot create: '+this.cHtmlFileName )
- return false
- endif
-
-
- // Stream Header
-
- fPuts(this.nHnd,'<HTML>')
- fPuts(this.nHnd,'')
- fPuts(this.nHnd,'<head>')
- fPuts(this.nHnd,'<meta http-equiv="Content-Type" content="text/html">')
- fPuts(this.nHnd,'<meta name="Generator" content="Visual dBASE 7 Web Wizard">')
- if not empty(this.oForm.FirstPageTitle.Editor1.value)
- fPuts(this.nHnd,'<title>'+this.oForm.FirstPageTitle.Editor1.value+'</Title>')
- endif
- fPuts(this.nHnd,'</head>')
- fPuts(this.nHnd,'')
-
- this.oform.progress1.value = 50
-
- fPuts(this.nHnd,' '+class::BuildBodyString())
- fPuts(this.nHnd,'')
- fPuts(this.nHnd,' <blockquote>')
-
- class::StreamTitleAndLogo()
-
- fPuts(this.nHnd,'')
- cHtml = class::BuildHTMLString(this.oForm.TextAboveDataEntry)
- if not empty(cHTML)
- fPuts(this.nHnd,' '+cHTML)
- endif
-
- fPuts(this.nHnd,'')
- fPuts(this.nHnd,' <Form METHOD="Get" Action="'+this.cCgiUrlBat+'">')
- fPuts(this.nHnd,'')
- // stream form controls
- class::StreamDataControls()
-
- // submit and reset buttons
- cAlign = iif(this.oform.cWizardType = 'Query','center',;
- iif(this.oForm.AlignDataCenterRadio.value,'center',;
- 'left'))
- fPuts(this.nHnd,' <DIV align="'+cAlign+'"><p></p><p><Input type="Submit" value="Submit" > '+;
- '<Input type="Reset" value = "Reset"></p></DIV>')
-
-
- fPuts(this.nHnd,' </Form>')
-
- fPuts(this.nHnd,'')
- cHTML = class::BuildHTMLString(this.oForm.TextBelowDataEntry)
- if not empty(cHTML)
- fPuts(this.nHnd,' '+cHTML)
- endif
-
- this.oform.progress1.value = 70
-
- class::StreamHomeandMail()
-
- this.oForm.progress1.value = 90
-
- fPuts(this.nHnd,' </blockquote>')
- fPuts(this.nHnd,' </body>')
- fPuts(this.nHnd,'</HTML>')
- fClose(this.nHnd)
- this.oform.progress1.value = 100
- this.oform.progress1.value = 0
- this.oform.finishlabel.text = 'Progress...'
-
- return true
-
- // Initialize URL
-
- ///////////Method: StreamtitleandLogo ////////////////////////////////
- //////////Purpose: Outputs title and logo image
-
- function StreamTitleAndLogo
-
- local cTitle
- cTitle = ltrim(trim(class::BuildHTMLString(this.oForm.FirstPageTitle)))
- // if title and logo on same line and both exist
-
- if this.oform.LeftOfTitleRadio.value and ;
- (not empty(this.logoImage)) and ;
- (not empty(this.oForm.firstPageTitle.editor1.value))
-
- // adjust tags to combine graphic and text in same line.
- local cFirst, cLast
- cFirst = ''
- cLast = ''
- if substr(cTitle,1,2) = '<H'
- //save begining of "header"
- cFirst = substr(cTitle,1,at('>',cTitle))
- //remove H tag and H end tag
- cTitle = substr(cTitle,at('>',cTitle)+1)
-
-
- endif
- fPuts(this.nHnd,' '+cFirst+'<img src="'+this.LogoImage+'"> '+ cTitle)
-
- else
-
- // Display logo at center or left, depending on radiobuttons
- if not empty(this.logoImage)
- cHtml = ' <p align="'
- cHtml+= iif(this.oform.TopCenterRadio.value,'center','left')
- cHtml+= '">'
- cHtml+='<img src="'+this.LogoImage+'">'
- cHtml+= '</p>'
-
- fPuts(this.nHnd,cHtml)
- // start a new line
- endif
-
- // Display title of page, if there is one
- if not empty(cTitle)
- fPuts(this.nHnd,' '+cTitle)
- endif
-
-
- endif
-
- return true
-
-
-
- ///////////Method: CopyGraphicFile ///////////////////////////////
- ///////////Purpose: Copies graphic files from source folder to
- /////////// HTML folder
-
- Function CopyGraphicFile(cSource)
-
- local cSourcePath, cFileName, cDestPath, cSaveSource
-
-
- cSourcePath = trim(ltrim(cSource))
-
-
- // see if no file specified
- if len(cSourcePath) = 0
- return ''
- endif
-
- //hard wire default path!
- if at('\',cSourcePath) = 0
- cSourcePath = trim(this.home)+cSourcePath
- endif
-
- //Strip out path to extract filename
- cFileName = trim(cSourcePath)
-
- if at('\',cFileName) > 0
- cFileName = substr(cFileName,rat('\',cFileName)+1)
- endif
-
- //Define destination path
- cDestPath = this.cHTMLPath+cFileName
-
-
- // This is a workaround of the "File Exists... Overwrite"
- // automatic dialog in order to do a "copy all"
-
- // if file already exists
- if file(cDestPath)
- // and they didn't already say 'Yes to all"
- if not this.bCopyAll
- // if they say "dont' overwrite"
- if not class::OverwriteFile(cDestPath)
- //forget it
- return cFile
- else
- //otherwise, delete the file so no
- //"overwrite" msgbox() will appear
- dele file (cDestPath)
- endif
-
- else
- // if it is already "copyall"
- // delete the file before copying
- dele file (cDestPath)
-
- endif
- endif
-
- // Try to copy file to HTML folder
- try
-
- Copy File (cSourcePath) to (cDestPath)
-
- catch (Exception e)
-
- msgbox('Cannot copy file '+cSourcePath+' to '+cDestPath+;
- chr(13)+e.message,'Copy Error',16)
- endtry
-
-
-
- Return cFileName
-
-
- ////////////Method: BuildBodyString ////////////////////////////
- ////////////Purpose: Builds string for HTML body attributes
- function BuildBodyString
-
-
- local cBody
- cBody = '<body '
- if not empty(this.oForm.BackgroundColorField.value)
- cBody += 'bgcolor="'+;
- class::HTMLColor(this.oForm.BackgroundcolorField.value)+;
- '"'
- endif
- if not empty(this.BackGroundImage)
- cBody += ' background="'+this.BackgroundImage+'"'
- endif
- cBody +='>'
- return cBody
-
-
-
-
-
- ///////////Method: HTMLColor ///////////////////////////////////
- ///////////Purpose: Converts VdB color string to HTML color string
- /////////// VdB colors are: 0xBGR
- /////////// HTML colors are: #RGB
- function HTMLColor(cColor)
- // if not a dBASE color string
- if at('0X',upper(cColor)) = 0
- return cColor
- endif
- // X0BBGGRR
- return '#'+substr(cColor,7,2)+substr(cColor,5,2)+;
- substr(cColor,3,2)
-
-
-
-
-
-
-
- ///////////Method: Stream Data Controls ///////////////////////////
- ///////////Purpose: Streams out controls for query and data-entry
-
- Function StreamDataControls
-
- // If this is a query page, stream query "get" controls
-
- if this.oForm.cWizardType = 'Query'
-
- // if it's a combobox (select) with options
- fPuts(this.nHnd,'')
-
- cHtml = ' <Center><P><P>'
- if this.oForm.ComboboxRadio.value
-
-
-
- cHtml += ' <Select name="SEARCH" size="1">'
- for n = 1 to alen(this.oform.aOptions,1)
- cOption = this.oForm.aOptions[n]
- cHtml+= ' <Option value="'+cOption+'">'+cOption+;
- '</Option>'
- next
- cHtml+=' </Select></P></P></DIV>'
-
- else // if it's a text field
-
-
- cHtml = ' <DIV align="center"><P><P>'
- cHtml += ' <Input type="Text" name="SEARCH" size="25">'
- cHtml += ' </P></P></DIV>'
-
-
- endif
- fPuts(this.nHnd,cHtml)
- fPuts(this.nHnd,'')
-
-
- return true
-
-
-
- endif
- //////////////////End of Query Wizard data object streaming
-
- //////////////////The following is for Data-Entry Wizard
-
- // Check if there are any selected fields!
- if alen(this.oForm.aSelectedFields,1) = 0
- return false //if not, forget it
- endif
-
- // Initialize data-source properties (for datamodule or table)
- this.cSource = trim(this.oForm.DataSourceField.value)
- this.cFile = iif(at('\',this.cSource) > 0,substr(this.cSource,;
- rat('\',this.cSource)+1),this.cSource)
-
- // number of field objects to be streamed
- nNumFields = alen(this.oForm.aSelectedFields,1)
-
-
-
-
-
-
- // open query or table
- if at('.DMD',this.cFile) > 0
-
- this.cDataType = 'Data Module'
- // get datamodule reference from file
-
-
- ////////// open datamodule source file using low-level File I/O
- ////////// uses this.nH, since this.nHnd is already open
- fDmd = new File()
- try
- fDmd.Open(this.cSource,"R")
- catch (Exception e)
- // if this fails, error and return
- msgbox('Unable to open disk file '+this.cSource)
- return false
- endtry
-
-
- ////////////////////// Extract .DMD data module class name
- cDmd = ''
- cStr = upper(fDmd.Gets())
- // loop through source looking for class statement
- do
-
-
- if at('CLASS',cStr) > 0 and at('OF DATAMODULE',cStr) > 0
- cDmd = trim(ltrim(substr(cStr,at('CLASS',cStr)+5)))
- cDmd = trim(ltrim(substr(cDmd,1,at('OF DATAMODULE',cDmd)-1)))
- exit
- endif
-
- cStr = upper(fDmd.gets())
-
- until fDmd.Eof()
-
- fDmd.Close() // close disk file
-
-
- if len(trim(cDmd)) = 0 // if no class found, go back
- msgbox('Cannot find Data Module class in '+this.cSource)
- return false
- endif
-
- ////////////////open data///////////////////////////////////////
-
- try
-
- this.dMod = new &cDmd.() // go ahead, instantiate data module
-
- catch (Exception e)
-
- msgbox('Unable to open Data Module '+this.cSource+chr(13);
- +e.message)
- return false
-
- endtry
-
-
- else // this is a table, not a data module
-
- this.cDataType = 'Table'
-
- ///////////////open data
-
- try
-
- this.q = new Query()
- this.q.SQL = 'Select * from "'+this.cSource+'"'
- this.q.active = true
-
- catch (Exception e)
-
- msgbox('Unable to open table '+this.cSource,'Open Error',16)
- return false
-
- endtry
-
- endif // endif .dmd or table
-
-
- // start table
-
- // Store table alignment for shorthand
- cAlign = iif(this.oForm.AlignDataCenterRadio.value,'center','left')
-
- fPuts(this.nHnd,' <DIV align="'+cAlign+'">')
- fPuts(this.nHnd,' <Table border="0"'+;
- ' cellpadding="4" cellspacing="0">')
-
- // for manipulation purposes, store referece to form's
- // selected fields array in aSelect
- // sSelect preserves the user's field order
-
-
- aSelect = this.oForm.aSelectedFields
-
- for n = 1 to alen(aSelect,1)
-
- //parse out query/name pairs of array element
- cLookup = ltrim(trim(aSelect[n]))
- cQuery = substr(aSelect[n],1,at('->',aSelect[n])-1)
- cName = trim(substr(aSelect[n],at('->',aSelect[n])+2))
-
- //get the type of control needed///////////////
- //as well as length and decimals
-
- if this.cDataType = 'Table'
- this.q.rowset.first()
- cType = this.q.rowset.fields[cName].type
- nLen = this.q.rowset.fields[cName].length
- nDecs = this.q.rowset.fields[cName].decimalLength
- else
- cType = 'this.dMod.'+cQuery+'.rowset.fields["'+;
- cName+'"].type'
- cType = &cType.
- cLen = 'this.dMod.'+cQuery+'.rowset.fields["'+;
- cName+'"].length'
- nLen = &cLen.
- cDecs = 'this.dMod.'+cQuery+'.rowset.fields["'+;
- cName+'"].decimalLength'
- nDecs = &cDecs
- endif
- //String length for HTML usage
- cLen = ltrim(trim(str(nlen,4)))
-
- // Look up user-defined label for this item (if any)
- // in query Wiztemp1
- cLabel = ''
-
- this.oForm.Wiztemp1.Rowset.Applylocate("Field = '"+cLookup+"'")
- if .not. this.oForm.Wiztemp1.Rowset.EndOfset
- cLabel = trim(this.oForm.Wiztemp1.Rowset.Fields['Label'].value)
- endif
- xName = cQuery+'*@'+cName
- cType = upper(cType)
-
- fPuts(this.nHnd,' <tr>') // add table row
-
- fPuts(this.nHnd,' <td>'+cLabel+'</td>') // Add label cell contents
-
- cHtml =' <td>' // add control cell
-
- if cType = 'MEMO'
- cHtml+='<textarea rows="2" cols="30" name= "'+xName+'"></textarea>'
- elseif cType = 'LOG'
- cHtml+='<Input type="checkbox" value="OFF" name="'+xName+'">'
- else
- cHtml+='<Input type="text" size="'+cLen+'" name="'+xName+'">'
- endif
-
- cHtml+= '</td>'
-
- fPuts(this.nHnd,cHtml)
-
- fPuts(this.nHnd,' </tr>')
-
- next
-
- fPuts(this.nHnd,' </Table></DIV>')
-
- return true
-
- //////////Method: StreamHomeAndMail ///////////////////////////////////////
- ////// ///Purpose: Streams out GIFs or text for Home and Mail
-
- Function StreamHomeAndMail
-
- local bDoMail, bDoHome, cHTML, bParaDone
- cAlign = iif(this.oForm.cWizardType = 'Query' or ;
- (this.oForm.cWizardType = 'Data' and ;
- this.oForm.AlignDataCenterRadio.value),;
- 'center','left')
-
- cHtml = ''
- bParaDone = false
-
- //first find out if the addresses and info needed exist
- bDoHome = not( empty(this.oform.HomeImageField.value) or;
- empty(this.oform.HomeURLField.value) )
- bDoMail = not( empty(this.oform.MailImageField.value) or;
- empty(this.oform.MailAddressField.value) )
-
-
- if bDoHome
- if not bParaDone
- cHtml+= '<DIV align="'+cAlign+'"><p></p>'
- bParaDone = true
- endif
-
- cUrl = trim(ltrim(this.oForm.HomeUrlField.value))
- if substr(upper(cUrl),1,7) # 'HTTP://'
- cUrl = 'http://'+cUrl
- endif
-
- if this.oForm.UseTextRadio.value
- cHtml += ;
- '<a href="'+cUrl+'">'+;
- trim(ltrim(this.oForm.HomeImageField.value))+;
- '</a>'
- else
- cHtml += ;
- '<a href="'+cUrl+'">'+;
- '<img src="'+trim(this.HomeImage)+'" border="0">'+;
- '</a>'
-
- endif
-
- endif
-
- if bDoMail
- if not bParaDone
- cHtml+= '<DIV align="'+cAlign+'"><p></p>'
- bParaDone = true
- endif
-
- if this.oForm.UseTextRadio.value
- cHtml += ;
- ' <a href="mailto:'+trim(ltrim(this.oform.MailAddressField.value))+'">'+;
- trim(ltrim(this.oForm.MailImageField.value))+;
- '</a>'
- else
- cHtml += ;
- ' <a href="mailto:'+trim(ltrim(this.oform.MailAddressField.value))+'">'+;
- '<img src="'+trim(this.Mailimage)+'" border="0">'+;
- '</a>'
-
- endif
- endif
-
- if bParaDone
- cHtml += '</DIV>'
- fPuts(this.nHnd,' '+cHtml)
- endif
- return cHtml
-
-
-
- //////////Method: CleanUpFolder
- //////////Purpose:Returns path trimmed with trailing backslash
- function CleanUpFolder(cPath)
- cPath = ltrim(trim(cPath))
- if substr(cPath,len(cPath),1) # '\'
- cPath +='\'
- endif
-
- return cPath
-
-
-
- ///////////////Method: BuildHTMLString////////////////////////////
- ///////////////Purpose: Reads HTMLget Container properties to
- /////////////// stream out HTML text
- ///////////////Param: Reference to HTML container on parent form
-
- function BuildHTMLString(oText)
-
-
- /* before you build HTML tagged string, remove any tags
- that may already exist
-
- */
- cStr = oText.Editor1.Value
-
- if empty(cStr)
- return ''
- endif
-
-
- // first, strip off endtags (if any)
- if at('</',cStr) > 0
-
- cStr = substr(cStr,1,at('</',cStr)-1)
-
- endif
-
- // Now, get rid of starting tags
- do while at('>',cStr) > 0
-
- cStr = substr(cStr,at('>',cStr)+1)
-
- enddo
-
-
- // Next, build string from "inside-out"
-
- // Attributes first
-
-
-
- if at('Underline',oText.AttribCombo.value) > 0
- cStr = '<U>'+cStr+'</U>'
- endif
- if at('Bold',oText.AttribCombo.value) > 0
- cStr = '<B>'+cStr+'</B>'
- endif
- if at('Italic',oText.AttribCombo.value) > 0
- cStr = '<I>'+cStr+'</I>'
- endif
-
-
-
-
- // Then, color and alignment
- //+o
- cStr = '<Font color="'+class::htmlColor(oText.ColorField.value)+'">'+;
- cStr+'</Font>'
-
-
-
- // Then, text style
-
- if at('Header',oText.FontCombo.value) > 0
- cStr = '<H'+ substr(oText.FontCombo.value,8,1)+;
- ' align='+iif(oText.AlignLeftRadio.value,'left','center')+;
- '>'+cStr+'</H'+substr(oText.FontCombo.value,8,1)+'>'
-
- else
- // Paragraph,alignment:
- cStr = '<P '+'align='+iif(oText.AlignLeftRadio.value,;
- "left", "center")+'>'+cStr+'</P>'
- endif
-
- return cStr
-
-
- ///////// Method: OverwriteFile ///////////////////////////////
- ///////// Purpose: Special msgbox() for overwriting existing files
- ///////// with a "yes to all"
- Function OverWriteFile(cFileName)
- this.bOverWrite = false
-
-
- this.oF = new form()
- with (this.oF)
- scaleFontBold = false
- height = 4.5909
- left = 26.7143
- autocenter = true
- top = 3
- width = 49.2857
- mdi = false
- text = "Overwrite"
- endwith
- this.oF.oParent = this
-
- this.oF.IMAGE1 = new IMAGE(this.oF)
- with (this.oF.IMAGE1)
- height = 1.5455
- left = 0.2857
- top = 0.3182
- width = 5.7143
- metric = 0 // Chars
- dataSource = "FILENAME Question.bmp"
- alignment = 4 // True Size
- borderStyle = 3 // None
- endwith
-
-
- this.oF.TEXT1 = new TEXT(this.oF)
- with (this.oF.TEXT1)
- height = 1.8182
- left = 8.1429
- top = 0.7273
- width = 37.1429
- metric = 0 // Chars
- colorNormal = "BtnText/BtnFace"
- fontSize = 8
- fontName = 'MS Sans Serif'
- text = '<p align="Center">'
- text+= 'File: '+trim(cFileName)+' already exists! Overwrite?'
- text+= '</p>'
- endwith
-
-
- this.oF.YESBUTTON = new PUSHBUTTON(this.oF)
- with (this.oF.YESBUTTON)
- onClick = {;form.oParent.bOverWrite = true;form.close()}
- height = 0.9545
- left = 7.5714
- top = 3.1364
- width = 10.7143
- text = "&Yes"
- metric = 0 // Chars
- fontSize = 8
- group = false
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
-
- this.oF.YESTOALLBUTTON = new PUSHBUTTON(this.oF)
- with (this.oF.YESTOALLBUTTON)
- onClick = {;form.oParent.bOverWrite = true;form.oParent.bCopyAll=true;form.close()}
- height = 0.9545
- left = 19.2857
- top = 3.1364
- width = 10.7143
- text = "Yes to &All"
- metric = 0 // Chars
- fontSize = 8
- group = false
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
- this.oF.NOBUTTON = new PUSHBUTTON(this.oF)
- with (this.oF.NOBUTTON)
- onClick = {;form.close()}
- height = 0.9545
- left = 31
- top = 3.1364
- width = 10.7143
- text = "&No"
- metric = 0 // Chars
- fontSize = 8
- group = false
- colorNormal = "BtnText/BtnFace"
- value = false
- endwith
-
- ?? chr(7)
- this.oF.ReadModal()
- return this.bOverWrite
-
-
-
- ///////////Method: StreamCGI ///////////////////////////////////////////
- ///////////Purpose: The other main method of class Out ///////////////////
- /////////// this method streams .prgs and bat files and //////////
- /////////// compiles and generates an .EXE //////////////////////
- function StreamCGI
-
- ///////////////// don't do it if it's a static publish
- ///////////////// all others stream CGI
-
- if this.oForm.cWizardType = 'Publish' and ;
- not this.oForm.LiveReportRadio.value
- return true
- endif
-
- this.oForm.Finishlabel.text = 'Streaming CGI code...'
- this.oForm.Finishlabel.visible = false // workaround for display prob.
- this.oForm.Finishlabel.visible = true
-
-
- Local n
- this.cClass = ''
- this.cDataType = 'Table'
-
- this.oForm.Finishlabel.Text = 'Streaming CGI...'
- this.oForm.progress1.value = 10
-
- ///////////////////Data-Entry Wizard setup /////////////////////////
- if this.oForm.cWizardType = 'Data Entry'
- ///// Paste up .prg path
- cPrgName = trim(this.oForm.FileNameField.value)
- cPrgPath = this.cCGIFolder+cPrgName+'.prg'
-
- /// this is for compatibility with the other wizards
- this.cReportName = cPrgName
- this.cReportPath = cPrgPath
-
- // Create an array for compile and build
- this.aObj = new array()
- this.aObj.add(cPrgPath)
-
-
-
- //Extract the datamodule name from the source file
- cQueryName = ''
- cDmodName = ''
- cQueryName = ''
- this.cDataPath = trim(this.oForm.dataSourceField.value)
-
- if upper(right(this.cDataPath,4)) = '.DMD'
- this.cDataType = 'Datamodule'
- this.aObj.add(this.cDataPath)
-
- ////// try to open the .dmd file
- try
- fDmd = new File()
- fDmd.Open(trim(this.cDataPath),"R")
- catch (Exception e)
- msgbox(e.message,'Data Module Open Error',16)
- return false
- endtry
-
- do
-
- cStr = trim(fDmd.Gets(this.nHnd))
-
- ////// if class declaration is found
- if at('CLASS ',upper(cStr)) > 0 and at('OF',upper(cStr)) > 0
- // get class name
- cStr = ltrim(substr(cStr,at('CLASS',upper(cStr))+5))
- cDModName = trim(substr(cStr,1,at(' ',cStr)-1))
- exit
- endif
-
- until fDmd.Eof()
-
- fDmd.Close()
- fDmd = ''
-
- // if no data module class name is found, forget it!
- if len(trim(cDmodName)) = 0
- msgbox('Cannot find class declaration in: '+cDataPath,;
- 'Data Module Error',16)
- return false
- endif
-
- else // if it's a table
-
- this.cDataType = 'Table'
- ////// get table name to use as query name
-
- cQueryName = substr(this.cDataPath,1, rat('.',this.cDataPath)-1)
-
- if at('\',cQueryName) > 0
- cQueryName = substr(cQueryName,rat('\',this.cDataPath)+1)
- endif
-
- endif
-
-
- ////////// if this is a live publish or query
- else
-
- ///// Paste up .prg path
- cPrgPath = this.cCGIFolder+This.cReportName+'.prg'
- cPrgName = this.cReportName+'.prg'
-
-
- // Create an array for compile and build
- this.aObj = new array()
- this.aObj.add(cPrgPath)
- this.aObj.add(this.cReportPath)
-
- this.oForm.progress1.value = 10
- ////// open the report file and check for "set procedure" statements
- ////// While doing that, get the report's class name, too.
-
-
- fRep = new File()
-
- try
- fRep.Open(this.cReportPath,'R')
-
- catch (Exception e)
-
- msgbox(e.message,'Fail Report Open',16)
- return false
- endtry
-
- do
-
- ////// parse out each line for a set proc statement
- cStr = upper(fRep.Gets())
- if at('SET PROC',cStr) > 0
- ////// if found, get the path and add it to the array
- cProc = trim( ltrim( substr(cStr,at(' TO ',cStr)+3) ) )
- ////// remove any "additive" statements
- if at('ADDI',upper(cProc))
- cProc = ltrim(trim(substr(cProc,1,at('ADDI',cProc)-1)))
- endif
- this.aObj.add(cProc)
- endif
-
- ////// get class name
- if at('CLASS',cStr) > 0 and at('REPORT',cStr) >0 ;
- and at('OF',cStr) > 0
- this.cClass = trim( ltrim( substr(cStr,at('CLASS',cStr)+5) ) )
- this.cClass = trim( ltrim( substr(this.cClass,1, at(' OF ',this.cClass)-1) ) )
- endif
-
- until fRep.Eof() // until done with file
-
- this.oform.progress1.value = 25
-
- ////// clean up
- fRep.close()
- frep = Null
-
-
- ////// Copy Trans.gif - required for reports
- if not file(this.cCgiFolder+'Trans.gif')
- try
-
- copy file(this.oForm.cLoadPath+'Trans.gif') to ;
- (this.cCGIFolder+'Trans.gif')
-
- catch (Exception e)
-
- msgbox('Unable to copy Trans.gif'+chr(13)+e.Message,;
- 'Copy Failed',16)
- return false
-
- endtry
-
- endif
-
- endif
-
- ////////// The following code is shared between all Wizard types
-
- ///// Create new .prg file
- if file(cPrgPath)
- dele file (cPrgPath)
- endif
- fPrg = new File()
- fPrg.Create(cPrgPath,'RA')
-
- this.oForm.progress1.value = 40
-
- n = len(cPrgName)+7 // to indent, for appearance only
-
- ////// header comments
- fPrg.Puts('/* '+cPrgName+' - Program file for server-side CGI execution')
- fPrg.Puts(space(n)+'Generated by the Visual dBASE 7 '+;
- this.oForm.cWizardType+' Web Wizard')
- fPrg.Puts(space(n)+'Date: '+dtoc(date())+' Time: '+time())
- fPrg.Puts('*/')
- fPrg.Puts(' ')
-
- ////// if Query, parse out the query string
- if this.oForm.cWizardType = 'Query'
- fPrg.Puts('////// Create query variable for response reports to use')
- fPrg.Puts('Public cSearch')
- fPrg.Puts('cSearch = " "')
- fPrg.Puts('cEnv = trim(GetEnv("QUERY_STRING"))')
- fPrg.Puts('if len(trim(cEnv)) > 0')
- fPrg.Puts(' cSearch = substr(cEnv,at("=",cEnv)+1)')
- fPrg.Puts('endif')
- fPrg.Puts('////// Remove terminating character, if any')
- fPrg.Puts('if at("%",cSearch) > 0')
- fPrg.Puts(' cSearch = substr(cSearch,1,at("%",cSearch)-1)')
- fPrg.Puts('endif')
- fPrg.Puts('')
-
- elseif this.oForm.cWizardType = 'Data Entry'
-
- fPrg.Puts('private aData, cStr')
- fPrg.Puts('aData = new array()')
- fPrg.Puts('////// Get the Query string from the environment')
- fPrg.Puts('cStr = getenv("QUERY_STRING")')
- fPrg.Puts('if len(trim(cStr)) = 0')
- fPrg.Puts(' errorPage("Message: No data received from server!",0)')
- fPrg.Puts('endif')
- fPrg.Puts(' ')
- fPrg.Puts('////// Parse it out to get name/value pairs')
- fPrg.Puts('do while at("=",cStr) > 0')
- fPrg.Puts(' /////// CGI uses "&" separators between pairs')
- fPrg.Puts(' if at("&",cStr) > 0 // if more than one pair left')
- fPrg.Puts(' cData = OEMFormat(substr(cStr,1,at("&",cStr)-1))')
- fPrg.Puts(' cStr = substr(cStr,at("&",cStr)+1)')
- fPrg.Puts(' ////// If last pair ')
- fPrg.Puts(' else')
- fPrg.Puts(' cData = OEMFormat(cStr) // take the whole string')
- fPrg.Puts(' cStr = " "')
- fPrg.Puts(' endif')
- fPrg.Puts(' ')
- fPrg.Puts(' if len(trim(cData)) > 0')
- fPrg.Puts(' aData.add(cData)')
- fPrg.Puts(' endif')
- fPrg.Puts('enddo')
- fPrg.Puts(' ')
- fPrg.Puts('/////// Sort array')
- fPrg.Puts('aData.Sort()')
- fPrg.Puts(' ')
- fPrg.Puts('////// Open Query or Data Module')
- if this.cDataType = 'Datamodule'
- fPrg.Puts('Set Procedure to '+this.cDataPath+' additive')
- fPrg.Puts('dMod = new '+cDModName+'()')
- else
- fPrg.Puts(cQueryName+' = new query()')
- cSql = 'Select * from '+'"'+this.cDataPath+'"'
- fPrg.Puts(cQueryName+'.sql = '+"'"+cSql+"'")
- fPrg.Puts(cQueryName+'.active = true')
- endif
- fPrg.Puts('////// sort array by query and field')
- fPrg.Puts('private n, cStr, bAppendDone, cQuery, cType, cRow')
- fPrg.Puts('cQuery = ""')
- fPrg.Puts('cType = ""')
- fPrg.Puts('cRow =""')
- fPrg.Puts('n=1')
- fPrg.Puts(' ')
- fPrg.Puts('////// Traverse array of field/value pairs and update')
- fPrg.Puts('////// rowset fields with data')
- fPrg.Puts(' ')
- fPrg.Puts('bAppendDone = false')
- fPrg.Puts(' ')
- fPrg.Puts('Do while n <= alen(aData,1)')
- fPrg.Puts(' ////// store array element for extraction')
- fPrg.Puts(' ////// format: Query*@Field=Data')
- fPrg.Puts(' cStr = trim(aData[n])')
- fPrg.Puts(' ')
- fPrg.Puts(' if at("=",cStr) > 0 // if a valid name/value pair')
- fPrg.Puts(' ////// extract query name')
- fPrg.Puts(' cQuery = substr(cStr,1,at("*@",cStr)-1)')
- fPrg.Puts(' ////// extract field name')
- fPrg.Puts(' cField = substr(cStr,at("*@",cStr)+2)')
- fPrg.Puts(' cField = substr(cField,1,at("=",cField)-1)')
- fPrg.Puts(' ////// extract data')
- fPrg.Puts(' cData = trim(substr(cStr,at("=",cStr)+1))')
- fPrg.Puts(' ////// find out the type of the field to be updated')
- if this.cDataType = 'Datamodule'
- fPrg.Puts(' cRow = "dMod."+cQuery+".Rowset"')
- else
- fPrg.Puts(' cRow = cQuery+".rowset"')
- endif
- cQuote = "'"+'"'+"'"
- cF = "'.Fields['+"
- ct = "'].type'"
- cStr = 'cType = cRow + '+cF+cQuote+'+cField+'+cQuote+'+"].type"'
- fPrg.Puts(' '+cStr)
- fPrg.Puts(' cType = &cType')
- fPrg.Puts(' ')
- fPrg.Puts(' ////// try to append new row')
- fPrg.Puts(' if not bAppendDone')
- fPrg.Puts(' cAppend = cRow+".beginappend()"')
- fPrg.Puts(' try')
- fPrg.Puts(' &cAppend.')
- fPrg.Puts(' catch (Exception e)')
- fPrg.Puts(' errorPage(e.message,e.Lineno)')
- fPrg.Puts(' endtry')
- fPrg.Puts(' endif')
- fPrg.Puts(' bAppendDone = true')
- fPrg.Puts(' ')
- fPrg.Puts(' ////// Set up "update strings" for Macro ')
- fPrg.Puts(' cUpdate = cRow')
- fPrg.Puts(' cF = '+cQuote+'+cField+'+cQuote)
- fPrg.Puts(' ')
- fPrg.Puts(' if cType = "LOGICAL"')
- fPrg.Puts(' cUpdate += ".fields["+cF+"].value = "+iif(cData = "Y",true,false)')
- fPrg.Puts(' ')
- fPrg.Puts(' elseif cType = "NUMERIC" or ;')
- fPrg.Puts(' cType = "INTEGER" or ;')
- fPrg.Puts(' cType = "LONG"')
- fPrg.Puts(' cUpdate += ".fields["+cF+"].value = "+val(cData)')
- fPrg.Puts(' ')
- fPrg.Puts(' elseif cType = "DATE"')
- fPrg.Puts(' cUpdate += ".fields["+cF+"].value = "+dtoc(cData)')
- fPrg.Puts(' ')
- fPrg.Puts(' elseif cType = "AUTOINCREMENT"')
- fPrg.Puts(' // do nothing!! Autoincrement is automatic')
- fPrg.Puts(' ')
- fPrg.Puts(' else')
- fPrg.Puts(' cUpdate += ".fields["+cF+"].value = "+'+cQuote+'+cData+'+cQuote)
- fPrg.Puts(' ')
- fPrg.Puts(' endif')
- fPrg.Puts(' endif')
- fPrg.Puts(' if cType # "AUTOINCREMENT"')
- fPrg.Puts(' Try')
- fPrg.Puts(' &cUpdate. // Update field')
- fPrg.Puts(' Catch (Exception e)')
- fPrg.Puts(' ErrorPage(e.message, e.lineno)')
- fPrg.Puts(' endtry')
- fPrg.Puts(' endif')
- fPrg.Puts(' ++n')
- fPrg.Puts(' Local bSaveData')
- fPrg.Puts(' bSaveData = false')
- fPrg.Puts(' ////// if element beyond last one in array')
- fPrg.Puts(' if n > alen(aData,1)')
- fPrg.Puts(' bSaveData = true')
- fPrg.Puts(' else')
- fPrg.Puts(' ////// determine if data is for a new query')
- fPrg.Puts(' cStr = aData[n]')
- fPrg.Puts(' ////// find out what query the next element uses')
- fPrg.Puts(' cNewQuery = substr(cStr,1,at("*@",cStr)-1)')
- fPrg.Puts(" ////// if it's different than previous, save current row")
- fPrg.Puts(' bSaveData = ( cNewQuery # cQuery )')
- fPrg.Puts(' endif')
- fPrg.Puts(' if bAppendDone and bSaveData')
- fPrg.Puts(' cSave = cRow+".Save()"')
- fPrg.Puts(' &cSave.')
- fPrg.Puts(' bAppendDone = false // reset for next query')
- fPrg.Puts(' ')
- fPrg.Puts(' endif')
- fPrg.Puts(' ')
- fPrg.Puts('enddo')
- fPrg.Puts(' ')
-
- fPrg.Puts('GenerateResponse() // return response page to Browser')
- fPrg.Puts('return // either response: error or thank you, quits.')
-
- fPrg.Puts('////////////////function GenerateResponse//////////////')
- fPrg.Puts('////////////////outputs "thank you" to CGI ////////////')
- fPrg.Puts('function GenerateResponse')
- fPrg.Puts(' If file("results.txt")')
- fPrg.Puts(' Delete file results.txt')
- fPrg.Puts(' Endif')
- fPrg.Puts(' ')
- fPrg.Puts(' fOut = new File()')
- fPrg.Puts(' fOut.Create("Results.txt","RA")')
- fPrg.Puts(' ')
- fPrg.Puts(' fOut.Puts("Content-type: text/html")')
- fPrg.Puts(' fOut.Puts(" ")')
- fPrg.Puts(' fOut.Puts("<HTML>")')
- fPrg.Puts(' fOut.Puts("<TITLE>Data Entered</TITLE>")')
- this.BackgroundImage= trim(this.oForm.BackGroundImageField.Value)
- fPrg.Puts(' fOut.Puts('+"'"+class::BuildBodyString()+"'"+')')
- fPrg.Puts(' fOut.Puts("<blockquote>")')
- cHtml = class::BuildHTMLString(this.oForm.TextOnResponsePage)
-
- if len(trim(cHtml)) = 0
- cHtml = 'Data entered successfully!'
- endif
- cHTML = '"'+class::SubstituteChars(cHTML)+'"'
-
- fPrg.Puts(' fOut.Puts('+cHtml+')')
- fPrg.Puts(' fOut.Puts("</Blockquote>")')
- fPrg.Puts(' fOut.Puts("</Body>")')
- fPrg.Puts(' fOut.Puts("</HTML>")')
- fPrg.Puts(' ')
- fPrg.Puts(' fOut.close()')
- fPrg.Puts(' Quit')
-
- endif // Data-Entry wizard
-
- if this.oForm.cWizardType # 'Data Entry'
- fPrg.Puts('////// Set procedure to report file')
- fPrg.Puts('Set procedure to '+this.cReportName+'.rep additive')
- fPrg.Puts('')
- fPrg.Puts('////// Instantiate report and set properties for HTML output')
- fPrg.Puts('r = new '+this.cClass+'()')
- fPrg.Puts('r.Output = 4 // HTML')
- fPrg.Puts('r.OutputFileName = "Report.txt"')
- fPrg.Puts('')
- fPrg.Puts(' ////// Run the report')
- fPrg.Puts('try')
- fPrg.Puts(' r.render()')
- fPrg.Puts('catch (Exception e)')
- fPrg.Puts(' ErrorPage(e.message)')
- fPrg.Puts('endtry')
-
- fPrg.Puts('////// Clean up')
- fPrg.Puts('r = false')
- fPrg.Puts('close proc '+this.cReportName)
- fPrg.Puts('')
- fPrg.Puts('////// See if report was rendered')
- fPrg.Puts('if not file("Report.txt")')
- fPrg.Puts(' ErrorPage(e.message)')
- fPrg.Puts('endif')
- fPrg.Puts('')
- fPrg.Puts('////// open report file')
- fPrg.Puts('fRep = new file()')
- fPrg.Puts('fRep.Open("Report.txt","R")')
- fPrg.Puts('')
- fPrg.Puts('////// Create new CGI response file')
- fPrg.Puts('')
- fPrg.Puts('if file("Results.txt")')
- fPrg.Puts(' dele file ("Results.txt")')
- fPrg.Puts('endif')
- fPrg.Puts('fOut = new file()')
- fPrg.Puts('fOut.Create("Results.txt","RA")')
- fPrg.Puts('')
- fPrg.Puts('////// read in report file after appending CGI header')
- fPrg.Puts('fOut.Puts("Content-type: text/html")')
- fPrg.Puts('fOut.Puts(" ")')
- fPrg.Puts('')
- fPrg.Puts('////// loop through report.txt and read into results.txt')
- fPrg.Puts('private cStr')
- fPrg.Puts('Do')
- fPrg.Puts(' cStr = fRep.Gets()')
- fPrg.Puts(' fOut.Puts(cStr)')
- fPrg.Puts('Until fRep.eof()')
- fPrg.Puts('' )
- fPrg.Puts('////// save results file')
- fPrg.Puts('fOut.close()')
- fPrg.Puts('fRep.close()')
- fPrg.Puts('////// all done')
- fPrg.Puts('Quit')
- fPrg.Puts('')
- fPrg.Puts('')
-
- endif
-
- // shared///////////////////////////////////////////////////
- fPrg.Puts('//////////// Function: ErrorPage //////////////////////////)')
- fPrg.Puts('//////////// Purpose: Returns error page if CGI fails //////')
- fPrg.Puts('//////////// Param: cMess = Error Message //////////////')
- fPrg.Puts('function ErrorPage(cMess,nLineNo)')
- fPrg.Puts('////// Create new results file')
- fPrg.Puts('if file("Results.txt")')
- fPrg.Puts(' dele file ("Results.txt")')
- fPrg.Puts('endif')
- fPrg.Puts('nLineNo = iif(empty(nLineNo),0,nLineNo)')
- fPrg.Puts('fOut = new file()')
- fPrg.Puts('fOut.Create("Results.txt","RA")')
- fPrg.Puts('fOut.Puts("")')
- fPrg.Puts('////// Generate HTML error page')
- fPrg.Puts('fOut.Puts("Content-type: text/html")')
- fPrg.Puts('fOut.Puts(" ")')
- fPrg.Puts('fOut.Puts("<HTML>")')
- fPrg.Puts('fOut.Puts("<HEAD><Title>Visual dBASE 7 Web Wizard Error Page</Title>")')
- fPrg.Puts('fOut.Puts("<BODY>")')
- fPrg.Puts('fOut.Puts("")')
- fPrg.Puts('fOut.Puts(" <H2><I>Sorry,an error ocurred on the host!</I></H2>")')
- fPrg.Puts('fOut.Puts("")')
- fPrg.Puts('fOut.Puts(" <P>Error:"+cMess+" </P>")')
- fPrg.Puts('fOut.Puts(" <P>Line No.: "+ltrim(str(nLineNo,5))+"</p>")')
- fPrg.Puts('fOut.Puts(" <P>Press the back button and try again, or contact the Web'+;
- 'master for assistance")')
- fPrg.Puts('fOut.Puts("")')
- fPrg.Puts('fOut.Puts("</BODY>")')
- fPrg.Puts('fOut.Puts("</HTML>")')
- fPrg.Puts('fOut.close()')
- fPrg.Puts('Quit')
-
- fPrg.Puts(' ')
- fPrg.Puts('///////////// Function OEMFormat //////////////////////////////')
- fPrg.Puts('///////////// Purpose - transforms CGI escape chars to OEM/////')
- fPrg.Puts('///////////// Param: cStr - Environment Variable Value ////////')
- fPrg.Puts('function OEMFormat(cStr)')
- fPrg.Puts(' ////// remove terminating character')
- fPrg.Puts(' if at("%21",cStr) > 0')
- fPrg.Puts(' cStr = substr(cStr,1,at("%21",cStr)-1)')
- fPrg.Puts(' endif')
- fPrg.Puts(' ////// remove "Pluses" used as space keepers in CGI')
- fPrg.Puts(' do while at("+",cStr) > 0')
- fPrg.Puts(' cStr = substr(cStr,1,at("+",cStr)-1) + " "+;')
- fPrg.Puts(' substr(cStr,at("+",cStr)+1)')
- fPrg.Puts(' enddo')
- fprg.Puts(' ////// add in "pluses" sent as escape characters')
- fPrg.Puts(' do while at("%2B",cStr) > 0')
- fPrg.Puts(' cStr = substr(cStr,1,at("%2B",cStr)-1) + "+" +;')
- fPrg.Puts(' substr(cStr,at("%2B",cStr)+3)')
- fPrg.Puts(' enddo')
- fPrg.Puts(' ////// add in "ampersands" sent as escape characters')
- fPrg.Puts(' do while at("%26",cStr) > 0')
- fPrg.Puts(' cStr = substr(cStr,1,at("%26",cStr)-1) + "&"+;')
- fPrg.Puts(' substr(cStr,at("%26",cStr)+3)')
- fPrg.Puts(' enddo')
- fPrg.Puts(' return cStr')
- fPrg.Close()
- fPrg = null
-
-
-
-
- private cBatPath
-
- ////// get full pathnames for .bat and .exe
- cBatPath = this.cCGIFolder+this.cReportName+'.bat'
-
- if file(cBatPath)
- dele file (cBatPath)
- endif
-
- cExePath = this.cCGIFolder+this.cReportName+'2.exe'
-
- fBat = new File()
- fBat.Create(cBatPath,'RA')
-
- fBat.Puts('@echo off')
- fBat.Puts('call '+this.cReportName+'2.exe')
- fBat.Puts('Type results.txt')
- fBat.Close()
- fBat = Null
-
-
- this.oForm.Finishlabel.text = 'Recompiling all files...'
- this.oForm.progress1.value = 80
-
- ////// re-compile all files
- for n =1 to alen(this.aObj,1)
-
- try
-
- if not empty(this.aObj[n])
- compile (this.aObj[n])
- endif
-
- catch (Exception e)
-
- msgbox(e.message,'Compile Failed: '+this.aObj[n],16)
- return false
-
- endtry
-
- next
-
- this.oForm.Finishlabel.text = 'Building .exe...'
- this.oForm.progress1.value = 90
-
- ////// Build a "build string"
- private cFile,cBuild
-
-
- cBuild = 'Build '+substr(this.aObj[1],1, len(this.aObj[1])-1)+'o'
-
-
- for n = 2 to alen(this.aObj,1)
- cFile = this.aObj[n]
- ////// paste the object file name
- cFile = '"'+substr(cFile,1,len(cFile)-1)+'o'+'"'
- cBuild += ' ,'+cFile
- next
-
- cBuild += ' To '+cExePath
-
-
-
- try
-
- &cBuild.
-
- catch (Exception e)
-
- msgbox(e.message,'EXE Build Error',16)
- return false
-
- endtry
-
-
- return true
-
- function SubstituteChars(cStr)
-
- do while at("'",cStr) > 0
-
- cStr = substr(cStr,1,at("'",cStr)-1) +;
- '''+substr(cStr,at("'",cStr)+1)
-
- enddo
-
- do while at('"',cStr) > 0
-
- cStr = substr(cStr,1,at('"',cStr)-1) +;
- '"'+substr(cStr,at('"',cStr)+1)
-
- enddo
-
-
- return cStr
- endclass
-
-
-